package controller;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;

import data.Data;

@SuppressWarnings("serial")
public class UpServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		resp.setCharacterEncoding("utf-8");
		
		String name = req.getParameter("name");
		DBCollection coll = Data.data("redomain");
		DBObject domain = coll.findOne(new BasicDBObject("name",name));
		
		if(domain == null)
		{
			BasicDBObject add = new BasicDBObject();
			add.put("name", name);
			add.put("status", 0);
			coll.insert(add);
		}
		
	}

}
